package com.qf.sy2103.ssm.service.impl;

import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import com.qf.sy2103.ssm.dao.LuyouDao;
import com.qf.sy2103.ssm.entity.Luyou;
import com.qf.sy2103.ssm.service.LuyouService;
import com.qf.sy2103.ssm.vo.PageVo;
import com.qf.sy2103.ssm.vo.TableVo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class LuyouServiceImpl implements LuyouService {
    @Autowired
    private LuyouDao luyouDao;
    @Override
    public TableVo<Luyou> all(PageVo pageVo, Luyou luyou) {
        PageHelper.startPage(pageVo.getPage(),pageVo.getLimit());
        List<Luyou> selectall = luyouDao.selectall(luyou);
        PageInfo pageInfo=new PageInfo<>(selectall);
        return new TableVo<Luyou>(0,"ok",pageInfo.getTotal(),selectall);
    }

    @Override
    public int add(Luyou luyou) {
        return luyouDao.insert(luyou);
    }

    @Override
    public int del(Integer[] id) {
        return luyouDao.delete(id);
    }

    @Override
    public int edit(Luyou luyou) {
        return luyouDao.update(luyou);
    }
}
